<template>
  <div :class="['todo-item',todo.completed?'completed':'']">
    <input type="checkbox" class="toggle" v-model="todo.completed">
    <label>{{todo.content}}</label>
    <button class="destory" @click="deleteTodo">x</button>
  </div>
</template>

<script>
export default {
  props: {
    todo: {
      type: Object,
      required: true
    }
  },
  methods: {
    deleteTodo () {
      this.$emit('del', this.todo.id)
    }
  }
}
</script>

<style lang="scss" scoped>
.todo-item {
  position: relative;
  font-size: 24px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  .toggle {
      width: 20px;
      height: 20px;
  }
  &:hover .destory {
      display: block;
  }
  label {
    white-space: pre-line;
    word-break: break-all;
    padding: 15px 60px 15px 15px;
    margin-left: 45px;
    display: inline-block;
    line-height: 1.2;
    transition: color 0.4s;
  }
  &.completed {
    label {
      color: #d9d9d9;
      text-decoration: line-through;
    }
  }
  .destory {
      display: none;
      margin-top:20px;
      border: none;
      float: right;
  }
}
</style>
